<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="models.StaffModel"%>
<%@page import="java.util.TreeMap"%>
<%@page import="helpers.UrlHelper"%>
<%
TreeMap check = (TreeMap) request.getAttribute("check");
String success = (String) request.getAttribute("success");
StaffModel user = (StaffModel) request.getAttribute("user");
String form = (String) request.getAttribute("form");
%>

<jsp:include page="/admin/layouts/header.jsp">
    <jsp:param name="language" value="1" />
</jsp:include>

<script type="text/javascript" src="/admin/js/form_staff.js"></script>
		
		<div class="maincontent noright">
        	<div class="maincontentinner">
                <ul class="maintabmenu multipletabmenu">
                	<li><a href="/admin/staff/list">Quản lý nhân viên</a></li>
                	<li class="current"><a href="/admin/staff/add"><%=form.equalsIgnoreCase("edit") ? "Thay đổi thông tin" : "Thêm nhân viên" %></a></li>
                </ul><!--maintabmenu-->
                
                <div class="content">
					<% if (success != null) {%>
					<div class="notification msgsuccess">
                        <a class="close"></a>
                        <p><%=success %></p>
                    </div>
					<% } %>
                    <div class="contenttitle">
                    	<h2 class="form"><span>Thông tin</span></h2>
                    </div><!--contenttitle-->
            
                    <form method="post" action="#" class="stdform stdform2" id="edit_user_form">
                    	
                        <p>
                        	<label>Tài khoản email</label>
                            <span class="field">
                            	<% if (!form.equalsIgnoreCase("add")) { %>
                            	<%=user.getUsername() %>
                            	<% } else { %>
                            	<input type="text" class="smallinput" name="username" id="u_username" value="<%=user.getUsername() != null ? user.getUsername() : "" %>">
                            	<% } %>
                            	<% if (check.get("username") != null) { %>
									<label for="u_username" generated="true" class="error"><%=check.get("username") %></label>
								<% } %>
                            </span>
                        </p>
                        <% if (form.equalsIgnoreCase("add")) { %>
                        <p>
                        	<label>Mật khẩu</label>
                            <span class="field">
                            	<input id="u_password" class="smallinput" type="password" name="password" value="<%=user.getPassword() != null ? user.getPassword() : "" %>" maxlength="100">
                            	 <% if (check.get("password") != null) { %>
									<label for="u_password" generated="true" class="error"><%=check.get("password") %></label>
								<% } %>
                            </span>
                        </p>
                        <p>
                        	<label>Nhập lại mật khẩu</label>
                            <span class="field">
                            	<input id="u_repassword" class="smallinput" type="password" name="repassword" value="<%=user.getRepassword() != null ? user.getRepassword() : "" %>" maxlength="100">
                            	 <% if (check.get("repassword") != null) { %>
									<label for="u_repassword" generated="true" class="error"><%=check.get("repassword") %></label>
								<% } %>
                            </span>
                        </p>
                        <% } %>
                        <p>
                        	<label>Họ tên</label>
                            <span class="field">
                            	<input id="u_fullname" class="mediuminput" type="text" name="name" value="<%=user.getName() != null ? user.getName() : "" %>" maxlength="100">
                            	 <% if (check.get("name") != null) { %>
									<label for="u_fullname" generated="true" class="error"><%=check.get("name") %></label>
								<% } %>
                            </span>
                        </p>
                        
                        <p>
                        	<label>Trạng thái</label>
                            <span class="field">
                            	<select id="u_status" name="status" class="smallinput">
									<option value="0" <%=user.getStatus() == 0 ? "selected=\"selected\"" : "" %>>Chưa kích hoạt</option>
									<option value="1" <%=user.getStatus() == 1 ? "selected=\"selected\"" : "" %>>Đang xác nhận</option>
									<option value="2" <%=user.getStatus() == 2 ? "selected=\"selected\"" : "" %>>Kích hoạt</option>
								</select>
								<% if (check.get("status") != null) { %>
									<label for="u_status" generated="true" class="error"><%=check.get("status") %></label>
								<% } %>
                            </span>
                        </p>
                        
                        <p>
                        	<label>Quyền truy cập</label>
                            <span class="field">
                            	<select id="u_role" name="role" class="smallinput">
									<option value="1" <%=user.getRole() == 1 ? "selected=\"selected\"" : ""%>>Sale</option>
									<option value="2" <%=user.getRole() == 2 ? "selected=\"selected\"" : ""%>>Bán hàng trực tiếp</option>
									<option value="3" <%=user.getRole() == 3 ? "selected=\"selected\"" : ""%>>Giao nhận</option>
									<option value="4" <%=user.getRole() == 4 ? "selected=\"selected\"" : ""%>>Kho</option>
									<option value="5" <%=user.getRole() == 5 ? "selected=\"selected\"" : ""%>>Điều phối, xuất tuyến</option>
									<option value="6" <%=user.getRole() == 6 ? "selected=\"selected\"" : ""%>>Kế toán</option>
									<option value="7" <%=user.getRole() == 7 ? "selected=\"selected\"" : ""%>>Marketing</option>
									<option value="8" <%=user.getRole() == 8 ? "selected=\"selected\"" : ""%>>CEO</option>
									<option value="9" <%=user.getRole() == 9 ? "selected=\"selected\"" : ""%>>Admin quản trị hệ thống</option>
								</select>
								<% if (check.get("role") != null) { %>
									<label for="u_role" generated="true" class="error"><%=check.get("role") %></label>
								<% } %>
                            </span>
                        </p>
                        
                        <p class="stdformbutton">
                        	<button class="submit radius2">Cập nhật</button>
                            <input type="reset" value="Trạng thái ban đầu" class="reset radius2">
                        </p>
                        
                    </form>
                    
                    <br clear="all">
                    
                </div><!--content-->
                
            </div><!--maincontentinner-->
            
            <jsp:include page="/admin/elements/copyright.jsp">
            	<jsp:param name="language" value="1" />
			</jsp:include>
            
        </div>

<jsp:include page="/admin/layouts/footer.jsp">
    <jsp:param name="language" value="1" />
</jsp:include>